import qs from 'qs'

export default $axios => ({
    addOrder(order) {
        return $axios.post('/server/order', order)
    },
    checkPayment(orderId) {
        return $axios.post('/server/pay', qs.stringify({
            orderId
        }))
    },
    updateOrderStatus(orderStatus) {
        return $axios.put('/server/order', qs.stringify({
            type: 'orderStatus',
            ...orderStatus
        }))
    },
    getOrderListByUserID(username) {
        return $axios.get('/server/order', {
            params: {
                type: 'getOrderListByUserID',
                id: username
            }
        })
    },
    getOrderByOrderId(orderId) {
        return $axios.get('/server/order', {
            params: {
                type: 'getOrder',
                id: orderId
            }
        })
    }
})